<?php

namespace app\controller;

use app\BaseController;
use app\common\model\Service as ModelService;
use think\facade\View;

class Service extends BaseController
{
    public function index()
    {
        $service_header_bg_img = get_sys_config('service_header_bg_img');
        View::assign('service_header_bg_img', $service_header_bg_img);

        $res  = ModelService::where(['status'=>1])->limit(5)->order('create_time','desc')->select()->toArray();
        foreach($res as $key => $value){
            if(empty($value['bg_img'])){
                $res[$key]['bg_img'] = '/assets/img/service_default.jpg';
            }
            $res[$key]['banner_path'] = json_decode($value['banner_path']);
        }
        View::assign('service', $res);
        return View::fetch();
    }
}
